#import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/EAGLDrawable.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>

#define MAX_TOUCHES 10

@interface EAGLView : UIView
{
@private
	/* The pixel dimensions of the backbuffer */
	GLint 					_backbuffer_width;
	GLint 					_backbuffer_height;
	
	//EAGLContext*			_context;
	
	/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
	GLuint					_frame_buffer;
	GLuint					_render_buffer;
	
	/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
	GLuint					_depth_buffer;
		
	int						_num_touches;
	UITouch*				_current_touches[MAX_TOUCHES];
	int						_touch_id_gen;
	int						_touches_id[MAX_TOUCHES];
}

- (id) initWithFrame:(CGRect)frame;

- (BOOL) CreateFramebuffer;
- (void) DestroyFramebuffer;

- (void) UpdateTouches:(UIEvent*)event;
- (int) GetTouchIndex: (UITouch*) touch;
- (void) AddTouch: (UITouch*) touch;
- (void) RemoveTouch: (UITouch*) touch;
- (void) ClearTouch;

@end
